home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
016a
/
gofer221.zip
/
MATCH
< prev
next >
Wrap
Text File
|
1991-11-20
|
853b
|
28 lines
match [] ys = null ys
match ('*':ps) xs = or (map (match ps) (tails xs))
match (p:ps) [] = False
match (p:ps) (c:cs)
| p==c = match ps cs
| otherwise = False
-- Some combinatorial problems:
tails [] = [[]]
tails xs'@(x:xs) = xs' : tails xs
inits [] = [[]]
inits (x:xs) = [] : map (x:) (inits xs)
perms [] = [[]]
perms (x:xs) = concat (map (inter x) (perms xs))
where inter x [] = [[x]]
inter x ys'@(y:ys) = (x:ys') : map (y:) (inter x ys)
subs [] = [[]]
subs (x:xs) = subs xs ++ map (x:) (subs xs)
segs = concat . map tails' . reverse . inits
where tails' [] = []
tails' xs'@(_:xs) = xs' : tails' xs